<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的模板</title>

</head>

<body>

    <button id="get">get请求</button>
    <button id="post">post请求</button>
</body>
<script src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
<script>
    var get = document.getElementById('get');
    var post = document.getElementById('post');

    get.onclick = function() {
        axios.get("https://autumnfish.cn/api/joke/list?num=5").then(
            function(response) {
                console.log(response);
            },

            function(error) {
                console.log(error);
            }
        )

    }
    post.onclick = function() {
        axios.post("https://autumnfish.cn/api/user/reg", {
            username: 'hxh'
        }).then(
            function(response) {
                console.log(response);
            },

            function(error) {
                console.log(error);
            }
        )

    }
</script>

</html>